<?php
/**
 * PHP madLib
 *
 * An open source PHP development library
 *
 * @package		madLib
 * @author			MadPitbull_99
 * @link				http://madhacking.com
 */

// ------------------------------------------------------------------------

 
 
class madLib
{
	
    //Propriedades de la clase
    private $version = " v0.4.4 ";
	public $debug, $file, $string, $security, $database, $pageLoadTime, $image, $url, $misc, $net;

/*------------------------------------------------------------------------------------------------------*/	
    /* Es el constructor de la clase
     *<cualquier codigo que se introduzca aqui
     * sera ejecutado cuando se cree un objeto
     * de esta clase>
	 */ 
    
    function __construct()
    {
		//Cargar módulos	
		$this->include_modules(__DIR__."/modules/");
		
		//Instanciar los objetos
		$this->debug 				= new mDebug();
		$this->file					= new mFile();
		$this->string 				= new mString();
		$this->security 			= new mSecurity();
		$this->database 			= new mDataBase();
		$this->pageLoadTime 	= new mPageLoadingTime();
		$this->image 				= new mImage();
		$this->url					= new mUrl();
		$this->net					= new mNet();
		
	}

/*------------------------------------------------------------------------------------------------------*/	
	
	/**
	 * Destruye todos los Objetos
	 */
	function closeLibrary(){
		unset($this->form);
		unset($this->files);
		unset($this->string);
		unset($this->security);
		unset($this->database);
		unset($this->pageLoadingTime);
		unset($this->image);
	}
/*------------------------------------------------------------------------------------------------------*/	
	/**
	* Incluye todos los modulos encontrados.
	* @return null
	*/
	function include_modules($modulePath){
		$pregPattern = "/module\.php$/";
		if ($files = @scandir($modulePath)){
			$filesCoincidentes = preg_grep($pregPattern,$files);
			foreach ($filesCoincidentes as $fileParaIncluir){
				if  (!@include($modulePath."/".$fileParaIncluir)){
					echo "El modulo ".$fileParaIncluir." no se puede incluir";
				}
			}
			
				
		}else{
			echo "No se puede acceder a la carpeta ".$modulePath;
		}
	}//include_modules
	
/*------------------------------------------------------------------------------------------------------*/	

	/**
	* Devuelve la version de madLib
	* @return string
	*/
    public function getVersion()
    {
        return $this->version;
    }

/*------------------------------------------------------------------------------------------------------*/	
		


		
		
} //End madLib
?>